<template>
  <div>
    <el-table
      :data="tableData"
      border
      stripe
      style="width: 100%"
    >
      <el-table-column
        prop="ordernum"
        label="订单号"
        min-width="130"
        align="center"
      />
      <el-table-column
        prop="cid"
        label="车辆编号"
        min-width="100"
        align="center"
      />
      <el-table-column
        prop="number"
        label="车牌号"
        min-width="120"
        align="center"
      />
      <el-table-column
        prop="brand"
        label="车辆品牌"
        min-width="130"
        align="center"
      />
      <el-table-column
        prop="name"
        label="客户姓名"
        min-width="130"
        align="center"
      />
      <el-table-column
        prop="tel"
        label="手机号码"
        min-width="130"
        align="center"
      />
      <el-table-column
        prop="ordertime"
        label="下单日期"
        min-width="100"
        width="100"
        align="center"
      />
      <el-table-column
        prop="picktime"
        label="取车日期"
        min-width="100"
        width="100"
        align="center"
      />
      <el-table-column
        prop="returntime"
        label="还车日期"
        min-width="100"
        width="100"
        align="center"
      />
      <el-table-column
        v-if="pageTitle === '订单管理'"
        label="车辆状态"
        min-width="80"
        align="center"
      >
        <template slot-scope="scope">
          <span>
            {{ scope.row.state === 0 ? '待取车' : scope.row.state === 1 ? '待还车' : '已还车' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column
        v-if="pageTitle === '待退押金'"
        prop="countdown"
        label="退款倒计时"
        min-width="95"
        align="center"
      />
      <el-table-column
        label="操作"
        min-width="100"
        align="center"
      >
        <template slot-scope="scope">
          <el-button
            v-if="pageTitle === '订单管理' || pageTitle === '收车故障'"
            type="primary"
            size="mini"
            plain
            @click="handleClick(scope.row)"
          >
            查看
          </el-button>
          <el-button
            v-if="pageTitle === '发车管理'"
            type="primary"
            size="mini"
            plain
            @click="handleClick(scope.row)"
          >
            发车
          </el-button>
          <el-button
            v-if="pageTitle === '收车管理'"
            type="primary"
            size="mini"
            plain
            @click="handleClick(scope.row)"
          >
            收车
          </el-button>
          <el-button
            v-if="pageTitle === '待退押金'"
            type="primary"
            size="mini"
            plain
            @click="handleClick(scope.row)"
          >
            退押金
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: 'PageTable',
  props: {
    tableData: {
      type: Array,
      default() {
        return []
      }
    },
    pageTitle: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleClick(row) {
      this.$emit('handle-click', row)
    }
  }
}
</script>

<style scoped>
</style>
